﻿using System.Drawing;

namespace InfoPathHelpers.RepeatingTable.Paginator
{
    /// <summary>
    /// Describes a column in a repeating table.
    /// </summary>
    public class RepeatingTableColumnDescription
    {
        const int DEFAULT_PADDING = 14;
        const double DEFAULT_WIDTH_ADJUST = 1d;

        public RepeatingTableColumnDescription() 
        {
            Padding = DEFAULT_PADDING;
            WidthAdjust = DEFAULT_WIDTH_ADJUST;
        }

        public RepeatingTableColumnDescription(string localName, int widthInPixels, bool isMultiLine)
        {
            LocalName = localName;
            Width = widthInPixels;
            IsMultiLine = isMultiLine;
            Padding = DEFAULT_PADDING;
            WidthAdjust = DEFAULT_WIDTH_ADJUST;
        }

        /// <summary>
        /// The local name of the repeating table column in the datasource.
        /// </summary>
        public string LocalName { get; set; }

        /// <summary>
        /// The width in pixels of the repeating table column.
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// A boolean value indicating whether or not the column can break across multiple lines.
        /// </summary>
        public bool IsMultiLine { get; set; }

        /// <summary>
        /// When printing different font sizes InfoPath prints some fonts larger or smaller 
        /// than what is displayed on the form view occasionally leading to unexpected line breaks.
        /// To account for this (as well as extra padding and margins) you can manually set the 
        /// WidthAdjust as a percentage e.g. 0.9 to force the paginator to count a string as multiple 
        /// lines if it is over 90% of the column width.
        /// Default: 1.0
        /// </summary>
        public double WidthAdjust { get; set; }

        /// <summary>
        /// The Padding is used to adjust the Width when calculating number of lines.
        /// It should include left and right cell padding and both padding and margins of controls inside the cell.
        /// This shoukd be adjusted if not using standard padding or margins.
        /// Default: 14 ((5 + 1 + 1) * 2)
        /// </summary>
        public int Padding { get; set; }

        /// <summary>
        /// The font used for text in this column.
        /// </summary>
        public Font Font { get; set; }
    }
}
